package com.lovegu.thread;

/**
 * @author 老顾
 * @title: TestDaemon
 * @projectName java-restudy
 * @email: 1437594522@qq.com
 * @date 2022/9/22 22:08
 */
public class TestDaemon {
    public static void main(String[] args) {
        God god = new God();
        You2 you2 = new You2();

        Thread thread = new Thread();
        thread.setDaemon(true); //默认是false，表示是false，正常线程都是用户线程

        thread.start();//上帝守护线程启动
        new Thread(you2).start();//用户线程启动
    }
}
//上帝
class God implements Runnable{
    @Override
    public void run() {
        while (true){
            System.out.println("上帝保佑着你");
        }
    }
}


//你
class You2 implements Runnable{
    @Override
    public void run(){
        for (int i = 0; i < 36500; i++) {
            System.out.println("你一生都开心的活着");
        }
        System.out.println("-=======goodbye world!");
    }
}
